[LOADER] Remove check for VIRT_BASE existence: it's not needed
authorkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Sun, 21 May 2006 08:55:15 +0000 (09:55 +0100)
committerkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Sun, 21 May 2006 08:55:15 +0000 (09:55 +0100)
to prevent xend crashign (when Aravindh's latest patch is
applied) and breaks ia64. Also, ensure we set a reasonable
default for elf_paddr_offset.

Signed-off-by: Keir Fraser <keir@xensource.com>
tools/libxc/xc_load_elf.c
xen/common/elf.c

index 33b07bdb3f7ed919974b078394e6bfaeb5dd407e..80256d18f861aa70eb28c20b3015b187b0d00c89 100644 (file)
@@ -148,14 +148,9 @@ static int parseelfimage(const char *image,
 
     dsi->xen_guest_string = guestinfo;
 
-    if ( (p = strstr(guestinfo, "VIRT_BASE=")) == NULL )
-    {
-        ERROR("Malformed ELF image. No VIRT_BASE specified");
-        return -EINVAL;
-    }
-
-    virt_base = strtoul(p+10, &p, 0);
-
+    virt_base = 0;
+    if ( (p = strstr(guestinfo, "VIRT_BASE=")) != NULL )
+        virt_base = strtoul(p+10, &p, 0);
     dsi->elf_paddr_offset = virt_base;
     if ( (p = strstr(guestinfo, "ELF_PADDR_OFFSET=")) != NULL )
         dsi->elf_paddr_offset = strtoul(p+17, &p, 0);
@@ -172,10 +167,18 @@ static int parseelfimage(const char *image,
             kernend = vaddr + phdr->p_memsz;
     }
 
-    if ( virt_base )
-        dsi->v_start = virt_base;
-    else
+    dsi->v_start = virt_base;
+    if ( dsi->v_start == 0 )
+    {
+        /*
+         * Legacy compatibility and images with no __xen_guest section:
+         * assume header addresses are virtual addresses, and that 
+         * guest memory should be mapped starting at kernel load address.
+         */
         dsi->v_start = kernstart;
+        if ( dsi->elf_paddr_offset == 0 )
+            dsi->elf_paddr_offset = dsi->v_start;
+    }
 
     dsi->v_kernentry = ehdr->e_entry;
     if ( (p = strstr(guestinfo, "VIRT_ENTRY=")) != NULL )
index 83155e0e08e65acd851e8118dfbeee20bce6c5de..ef74673ab3f058dec0d1139e931e03a6ca9dc78f 100644 (file)
@@ -103,10 +103,18 @@ int parseelfimage(struct domain_setup_info *dsi)
             kernend = vaddr + phdr->p_memsz;
     }
 
-    if ( virt_base )
-        dsi->v_start = virt_base;
-    else
+    dsi->v_start = virt_base;
+    if ( dsi->v_start == 0 )
+    {
+        /*
+         * Legacy compatibility and images with no __xen_guest section:
+         * assume header addresses are virtual addresses, and that 
+         * guest memory should be mapped starting at kernel load address.
+         */
         dsi->v_start = kernstart;
+        if ( dsi->elf_paddr_offset == 0 )
+            dsi->elf_paddr_offset = dsi->v_start;
+    }
 
     dsi->v_kernentry = ehdr->e_entry;
     if ( (p = strstr(guestinfo, "VIRT_ENTRY=")) != NULL )